package com.clqteam.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * 订单详情控制层
 * @author ZHX
 *
 */
import javax.servlet.http.HttpSession;

import com.clqteam.service.OrderInfoService;
import com.clqteam.serviceimpl.OrderInfoServiceImpl;

import net.sf.json.JSONObject;
public class OrderInfoController extends HttpServlet {
	
	OrderInfoService oiSer = new OrderInfoServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//设置字符集
		req.setCharacterEncoding("UTF8");
		resp.setCharacterEncoding("UTF8");
		//获取页面分页信息
		HttpSession session = req.getSession();
		int oId = (int)session.getAttribute("oId");
		int page = Integer.parseInt(req.getParameter("page"));
		int rows = Integer.parseInt(req.getParameter("rows"));
		//获取数据库数据
		JSONObject j = oiSer.findOrderInfoByOId(oId, page, rows);
		//回写
		PrintWriter pw = resp.getWriter();
		pw.write(j.toString());
		pw.flush();
		pw.close();
		
	}

}
